package com.elpebe.sysabk.service.impl;

import java.util.Date;

import javax.inject.Inject;

import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Service;

import com.elpebe.sysabk.model.Account;
import com.elpebe.sysabk.repository.IAccountRepository;
import com.elpebe.sysabk.service.AbstractService;
import com.elpebe.sysabk.service.IAccountService;

@Service
public class AccountService extends AbstractService<Account> implements IAccountService {

	@Inject IAccountRepository mRepository; 
	
	@Override
	protected PagingAndSortingRepository<Account, Long> getDao() {
		return mRepository;
	}
	
	@Override
	public Account update(Account entity) {
		Account updated = findOne(entity.getId());
		updated.setAddress(entity.getAddress());
		updated.setCity(entity.getCity());
		updated.setEmail(entity.getEmail());
		updated.setFirstName(entity.getFirstName());
		updated.setLastName(entity.getLastName());
		updated.setLastUpdate(new Date());
		updated.setPhoneNumber(entity.getPhoneNumber());
		updated.setState(entity.getState());
		return super.update(updated);
	}
	
}
